package com.sooth.system.log.service;

import com.dream.boot.impl.ServiceImpl;
import com.sooth.common.log.event.OperLogEvent;
import com.sooth.system.log.view.SysOperLogBo;
import com.sooth.system.log.view.SysOperLogVo;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogVo, SysOperLogBo> implements ISysOperLogService {

    @Async
    @EventListener
    public void recordLoginLog(OperLogEvent operLogEvent) {
        SysOperLogBo operLog = new SysOperLogBo();
        operLog.setTenantId(operLogEvent.getTenantId());
        operLog.setTitle(operLogEvent.getTitle());
        operLog.setMessage(operLogEvent.getMessage());
        operLog.setMethod(operLogEvent.getMethod());
        operLog.setRequestMethod(operLogEvent.getRequestMethod());
        operLog.setOperName(operLogEvent.getOperName());
        operLog.setOperUrl(operLogEvent.getOperUrl());
        operLog.setOperIp(operLogEvent.getOperIp());
        operLog.setOperParam(operLogEvent.getOperParam());
        operLog.setStatus(operLogEvent.getStatus());
        operLog.setErrorMsg(operLogEvent.getErrorMsg());
        operLog.setOperTime(operLogEvent.getOperTime());
        operLog.setCostTime(operLogEvent.getCostTime());
        super.insert(operLog);
    }
}
